package org.jeecg.modules.basic.demo.bed.controller;


import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.alibaba.fastjson.JSON;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.CommonAPI;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.system.vo.SysUserCacheInfo;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.basic.demo.apartment.entity.LwgyBaseApartment;
import org.jeecg.modules.basic.demo.apartment.service.ILwgyBaseApartmentService;
import org.jeecg.modules.basic.demo.bed.entity.*;
import org.jeecg.modules.basic.demo.bed.service.ILwgyBaseBedService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;

import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.basic.demo.school.entity.LwgyBaseSchool;
import org.jeecg.modules.basic.demo.school.service.ILwgyBaseSchoolService;
import org.jeecg.modules.basic.demo.student.entity.LwgyBaseStudent;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;

import static org.jeecg.modules.basic.demo.bed.service.impl.LwgyBaseBedServiceImpl.bedSet;

/**
 * @Description: 床位信息
 * @Author: jeecg-boot
 * @Date: 2021-01-20
 * @Version: V1.0
 */
@Api(tags = "床位信息")
@RestController
@RequestMapping("/bed/lwgyBaseBed")
@Slf4j
public class LwgyBaseBedController extends JeecgController<LwgyBaseBed, ILwgyBaseBedService> {
    @Autowired
    private ILwgyBaseBedService lwgyBaseBedService;

    @Autowired
    private ILwgyBaseApartmentService lwgyBaseApartmentService;

    @Autowired
    private ISysBaseAPI sysBaseAPI;

    @Autowired
    private CommonAPI commonAPI;

    @Autowired
    private ILwgyBaseSchoolService lwgyBaseSchoolService;

    /**
     * 分页列表查询
     *
     * @param lwgyBaseBed
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "床位信息-分页列表查询")
    @ApiOperation(value = "床位信息-分页列表查询", notes = "床位信息-分页列表查询")
    @GetMapping(value = "/list")
    public Result<?> queryPageList(LwgyBaseBed lwgyBaseBed,
                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<LwgyBaseBed> queryWrapper = QueryGenerator.initQueryWrapper(lwgyBaseBed, req.getParameterMap());
        Page<LwgyBaseBed> page = new Page<LwgyBaseBed>(pageNo, pageSize);
        IPage<LwgyBaseBed> pageList = lwgyBaseBedService.page(page, queryWrapper);
        return Result.OK(pageList);
    }

    /**
     * 床位安排分页列表查询
     *
     * @param lwgyBaseBed
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "床位安排-分页列表查询")
    @ApiOperation(value = "床位安排-分页列表查询", notes = "床位安排-分页列表查询")
    @GetMapping(value = "/listCustom")
    public Result<?> queryPageListCustom(LwgyBaseBed lwgyBaseBed,
                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                         @RequestParam(name = "studentName",required = false) String studentName,
                                         @RequestParam(name = "studentNumber",required = false) String studentNumber,
                                         @RequestParam(name = "roomSex",required = false) String roomSex,
                                         @RequestParam(name = "studentCampus",required = false) String studentCampus,
                                         @RequestParam(name = "studentCollege",required = false) String studentCollege,
                                         @RequestParam(name = "studentMajor",required = false) String studentMajor,
                                         @RequestParam(name = "studentClass",required = false) String studentClass,
                                         @RequestParam(name = "studentYear",required = false) String studentYear,
                                         @RequestParam(name = "studentEducation",required = false) String studentEducation,
                                         @RequestParam(name = "studentState",required = false) String studentState,
                                         @RequestParam(name = "studentSchoolSystem",required = false) String studentSchoolSystem,
                                         @RequestParam(name = "studentLeaveschool_begin",required = false) String studentLeaveschool_begin,
                                         @RequestParam(name = "studentLeaveschool_end",required = false) String studentLeaveschool_end,
                                         HttpServletRequest req) {
        String type = lwgyBaseBed.getType();
        String id = lwgyBaseBed.getId();
        if(oConvertUtils.isEmpty(type)){
            LwgyBaseApartment lwgyBaseApartment = lwgyBaseApartmentService.getById(id);
            type = lwgyBaseApartment.getType();
        }

        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<String> role = lwgyBaseBedService.getRoleById(sysUser.getId());
        if (role.contains("fdy")) {//不是管理员，显示管理员分配的的床位
            String workNo = sysUser.getWorkNo();
            System.err.println("work"+workNo);
            lwgyBaseBed.setAdminId(workNo);
        }
        if (role.contains("yanjiusheng")) {
            String workNo = sysUser.getWorkNo();
            System.err.println("workKKKKK"+workNo);
            lwgyBaseBed.setAdminId(workNo);
        }
        if (type != null) {
            switch (type) {
                case "campus":
                    lwgyBaseBed.setCampusId(id);
                    break;
                case "building":
                    lwgyBaseBed.setBuildingId(id);
                    break;
                case "unit":
                    lwgyBaseBed.setUnitId(id);
                    break;
                case "layer":
                    lwgyBaseBed.setLayerId(id);
                    break;
                case "room":
                    lwgyBaseBed.setRoomId(id);
                    break;
                default:
                    break;
            }
        }

        lwgyBaseBed.setId(null);
        lwgyBaseBed.setStudentCampus(null);
        lwgyBaseBed.setStudentCollege(null);
        lwgyBaseBed.setStudentYear(null);
        lwgyBaseBed.setStudentMajor(null);
        lwgyBaseBed.setStudentClass(null);

        QueryWrapper<LwgyBaseBed> queryWrapper = QueryGenerator.initQueryWrapper(lwgyBaseBed, req.getParameterMap());
        Page<LwgyBaseBed> page = new Page<>(pageNo, pageSize);
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf.format(date);

       if (StringUtils.isNotBlank(roomSex)) {
            queryWrapper.eq("t1.room_sex", roomSex);
        }
        if (StringUtils.isNotBlank(studentName)){
            queryWrapper.eq("t1.student_name",studentName);
        }
        if (StringUtils.isNotBlank(studentNumber)){
            queryWrapper.eq("t1.student_number",studentNumber);
        }
        if (StringUtils.isNotBlank(studentCampus)){
            queryWrapper.eq("t1.student_campus",studentCampus);
        }
        if (StringUtils.isNotBlank(studentCollege) && !studentCollege.equals("A")){
            queryWrapper.eq("t1.student_college",studentCollege);
        }

        if (StringUtils.isNotBlank(studentYear)){
            if(studentCollege.equals("A")){
                queryWrapper.eq("t1.year_name",studentYear);
            } else {
                queryWrapper.eq("t1.student_year",studentYear);
            }
        }

        if (StringUtils.isNotBlank(studentMajor)){
            queryWrapper.eq("t1.student_major",studentMajor);
        }
        if (StringUtils.isNotBlank(studentClass)){
            queryWrapper.eq("t1.student_class",studentClass);
        }
        if (StringUtils.isNotBlank(studentEducation)){
            queryWrapper.eq("t1.student_education",studentEducation);
        }
        if (StringUtils.isNotBlank(studentState)){
            queryWrapper.eq("t1.student_state",studentState);
        }
        if (StringUtils.isNotBlank(studentSchoolSystem)){
            queryWrapper.eq("t1.student_school_system",studentSchoolSystem);
        }
        if (StringUtils.isNotBlank(studentLeaveschool_begin) && StringUtils.isBlank(studentLeaveschool_end)){
            queryWrapper.le("t1.student_leaveschool",studentLeaveschool_end);
            queryWrapper.ge("t1.student_leaveschool",studentLeaveschool_begin);
        }
        queryWrapper.eq("t1.del_flag",0);
        queryWrapper.eq("room_type","hotel_room");
        queryWrapper.orderByAsc("t1.room_id");

        IPage<LwgyBaseBed> pageList2 = lwgyBaseBedService.queryPageListHotelInfo(page, queryWrapper);
        return Result.OK(pageList2);
    }

    /**
     * 床位管理分页列表查询
     *
     * @param lwgyBaseBed
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "床位管理-分页列表查询")
    @ApiOperation(value = "床位管理-分页列表查询", notes = "床位管理-分页列表查询")
    @GetMapping(value = "/listAllBed")
    public Result<?> queryPageListAllBed(LwgyBaseBed lwgyBaseBed,
                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                         @RequestParam(name = "delFlag",required = false) String delFlag,
                                         HttpServletRequest req) {
        String type = lwgyBaseBed.getType();
        String id = lwgyBaseBed.getId();
        if(oConvertUtils.isEmpty(type)){
            LwgyBaseApartment lwgyBaseApartment = lwgyBaseApartmentService.getById(id);
            type = lwgyBaseApartment.getType();
        }

        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<String> role = lwgyBaseBedService.getRoleById(sysUser.getId());
        if (role.contains("fdy")) {//不是管理员，显示管理员分配的的床位
            String workNo = sysUser.getWorkNo();
            lwgyBaseBed.setAdminId(workNo);
        }
        if (type != null) {
            if ("school".equals(type)) {
                lwgyBaseBed.setSchoolId(id);
            } else if ("campus".equals(type)) {
                lwgyBaseBed.setCampusId(id);
            } else if ("faculty".equals(type)) {
                lwgyBaseBed.setFacultyId(id);
            } else if ("building".equals(type)) {
                lwgyBaseBed.setBuildingId(id);
            } else if ("unit".equals(type)) {
                lwgyBaseBed.setUnitId(id);
            } else if ("layer".equals(type)) {
                lwgyBaseBed.setLayerId(id);
            } else if ("room".equals(type)) {
                lwgyBaseBed.setRoomId(id);
            }
        }
        lwgyBaseBed.setId(null);
        QueryWrapper<LwgyBaseBed> queryWrapper = QueryGenerator.initQueryWrapper(lwgyBaseBed, req.getParameterMap());
        Page<LwgyBaseBed> page = new Page<>(pageNo, pageSize);

        if (StringUtils.isNotBlank(delFlag)) {
            queryWrapper.eq("del_flag", delFlag);
        }
        queryWrapper.eq("room_type","hotel_room");
        queryWrapper.orderByAsc("room_id");

        IPage<LwgyBaseBed> pageList2 = lwgyBaseBedService.queryPageListAllBed(page, queryWrapper);
        return Result.OK(pageList2);
    }

    /**
     * 卫生打分信息分页列表查询
     *
     * @param lwgyBaseBed
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "卫生打分信息-分页列表查询")
    @ApiOperation(value = "卫生打分信息-分页列表查询", notes = "卫生打分信息-分页列表查询")
    @GetMapping(value = "/listCustomScore")
    public Result<?> queryPageListCustomScore(LwgyBaseBed lwgyBaseBed,
                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                              @RequestParam(name = "scaleBatches",required = false) String scaleBatches,
                                              @RequestParam(name = "studentCampus",required = false) String studentCampus,
                                              @RequestParam(name = "studentCollege",required = false) String studentCollege,
                                              @RequestParam(name = "totalScore",required = false) String totalScore,
                                              HttpServletRequest req) {
        String type = lwgyBaseBed.getType();
        String id = lwgyBaseBed.getId();
        if(oConvertUtils.isEmpty(type)){
            LwgyBaseApartment lwgyBaseApartment = lwgyBaseApartmentService.getById(id);
            type = lwgyBaseApartment.getType();
        }
        QueryWrapper<LwgyBaseBed> queryWrapper = new QueryWrapper<>();
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<String> role = lwgyBaseBedService.getRoleById(sysUser.getId());
        if (role.contains("fdy")) {//不是管理员，显示管理员分配的的床位
            String workNo = sysUser.getWorkNo();
            queryWrapper.eq("admin_id",workNo);
            lwgyBaseBed.setAdminId(workNo);
        }
        lwgyBaseBed.setId(null);
        //QueryWrapper<LwgyBaseBed> queryWrapper = QueryGenerator.initQueryWrapper(lwgyBaseBed, req.getParameterMap());
        if (type != null) {
            if ("school".equals(type)) {
                /*queryWrapper.eq();
                lwgyBaseBed.setSchoolId(id);*/
            } else if ("campus".equals(type)) {
                queryWrapper.eq("vb.campus_id",id).isNotNull("vb.student_id").ne("vb.student_id","");

            } else if ("faculty".equals(type)) {
                queryWrapper.eq("vb.faculty_id",id).isNotNull("vb.student_id").ne("vb.student_id","");

            } else if ("building".equals(type)) {
                queryWrapper.eq("vb.building_id",id).isNotNull("vb.student_id").ne("vb.student_id","");

            } else if ("unit".equals(type)) {
                queryWrapper.eq("vb.unit_id",id).isNotNull("vb.student_id").ne("vb.student_id","");

            } else if ("layer".equals(type)) {
                queryWrapper.eq("vb.layer_id",id).isNotNull("vb.student_id").ne("vb.student_id","");

            } else if ("room".equals(type)) {
                queryWrapper.eq("vb.room_id",id).isNotNull("vb.student_id").ne("vb.student_id","");
            }
        }

        Page<LwgyBaseBed> page = new Page<>(pageNo, pageSize);

        if (StringUtils.isNotBlank(studentCampus)) {
            queryWrapper.eq("ls.student_campus",studentCampus);
        }
        if (StringUtils.isNotBlank(studentCollege)){
            queryWrapper.eq("ls.student_college",studentCollege);
        }
        if (StringUtils.isNotBlank(totalScore)){
            queryWrapper.eq("total_score",totalScore);
        }
        //queryWrapper.isNotNull("vb.student_id").ne("vb.student_id","");
        queryWrapper.groupBy("vb.room_id");
        queryWrapper.orderByAsc("vb.room_id");
        IPage<LwgyBaseBed> pageList2 = lwgyBaseBedService.queryPageListCustomScore(page,scaleBatches,queryWrapper);
        return Result.OK(pageList2);
    }

    /**
     * 自定义分页列表查询
     *
     * @param lwgyBaseBed
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "床位信息-分页列表查询")
    @ApiOperation(value = "床位信息-分页列表查询", notes = "床位信息-分页列表查询")
    @GetMapping(value = "/listCustom2")
    public Result<?> listCustom2(LwgyBaseBed lwgyBaseBed,
                                 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                 HttpServletRequest req) {
        String type = lwgyBaseBed.getType();
        String id = lwgyBaseBed.getId();

        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String selectedSchools = sysUser.getSelectedSchools();
        String[] fields = selectedSchools.split(",");
        List<String> fieldList = Arrays.asList(fields);

        QueryWrapper<LwgyBaseSchool> wrapper = new QueryWrapper();
        wrapper.in("sys_org_code", fieldList);
        List<LwgyBaseSchool> list = lwgyBaseSchoolService.getBaseMapper().selectList(wrapper);
        for (LwgyBaseSchool lwgyBaseSchool : list) {
            String id1 = lwgyBaseSchool.getId();
        }

        if (type == null) {
            LwgyBaseApartment lwgyBaseApartment = lwgyBaseApartmentService.getById(id);
            type = lwgyBaseApartment.getType();
        }
        if (type != null) {
            if ("school".equals(type)) {
                lwgyBaseBed.setSchoolId(id);
            } else if ("campus".equals(type)) {
                lwgyBaseBed.setCampusId(id);
            } else if ("faculty".equals(type)) {
                lwgyBaseBed.setFacultyId(id);
            } else if ("building".equals(type)) {
                lwgyBaseBed.setBuildingId(id);
            } else if ("unit".equals(type)) {
                lwgyBaseBed.setUnitId(id);
            } else if ("layer".equals(type)) {
                lwgyBaseBed.setLayerId(id);
            } else if ("room".equals(type)) {
                lwgyBaseBed.setRoomId(id);
            }
        }
        lwgyBaseBed.setId(null);
        QueryWrapper<LwgyBaseBed> queryWrapper = QueryGenerator.initQueryWrapper(lwgyBaseBed, req.getParameterMap());
        for (int i = 0; i < list.size(); i++) {
            if ("campus".equals(list.get(i).getUniversitySort())) {
                if (i >= list.size() - 1) {
                    queryWrapper.eq("ls.campus_id", list.get(i).getId());
                } else {
                    queryWrapper.eq("ls.campus_id", list.get(i).getId()).or();
                }
            } else if ("faculty".equals(list.get(i).getUniversitySort())) {
                if (i >= list.size() - 1) {
                    queryWrapper.eq("ls.faculty_id", list.get(i).getId());
                } else {
                    queryWrapper.eq("ls.faculty_id", list.get(i).getId()).or();
                }
            } else if ("major".equals(list.get(i).getUniversitySort())) {
                if (i >= list.size() - 1) {
                    queryWrapper.eq("ls.student_major", list.get(i).getId());
                } else {
                    queryWrapper.eq("ls.student_major", list.get(i).getId()).or();
                }
            } else if ("class".equals(list.get(i).getUniversitySort())) {
                if (i >= list.size() - 1) {
                    queryWrapper.eq("ls.student_class", list.get(i).getId());
                } else {
                    queryWrapper.eq("ls.student_class", list.get(i).getId()).or();
                }
            }
        }
        Page<LwgyBaseBed> page = new Page<>(pageNo, pageSize);

        queryWrapper.orderByAsc("name");
        IPage<LwgyBaseBed> pageList2 = lwgyBaseBedService.queryPageListCustom(page, queryWrapper);
        return Result.OK(pageList2);
    }

    /**
     * 根据部门id查询用户信息
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/queryBedByScInfoId", method = RequestMethod.GET)
    public Result<?> queryBedByScInfoId(@RequestParam(name = "id", required = false) String id,/*@RequestBody LwgyBaseApartment lwgyBaseApartment0,*/
                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                        @RequestParam(name = "roomSex", required = false) String roomSex) {
        if (id == null) {
            return Result.OK(null);
        }
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String selectedSchools = sysUser.getSelectedSchools();
        String[] fields = selectedSchools.split(",");
        List<String> fieldList = Arrays.asList(fields);

        QueryWrapper<LwgyBaseSchool> wrapper = new QueryWrapper();
        wrapper.in("sys_org_code", fieldList);
        List<LwgyBaseSchool> list = lwgyBaseSchoolService.getBaseMapper().selectList(wrapper);
        Map<String, String> map = new HashMap<>(3);


        LwgyBaseApartment lwgyBaseApartment = lwgyBaseApartmentService.getById(id);
        Page<LwgyBaseBed> page = new Page<>(pageNo, pageSize);
        //List<LwgyBaseBed> userList = lwgyBaseBedService.queryBedByScInfoId(page, lwgyBaseApartment, roomSex);
        LwgyBaseBed lwgyBaseBed = new LwgyBaseBed();
        String type = lwgyBaseApartment.getType();
        if ("campus".equals(type)) {
            lwgyBaseBed.setCampusId(id);
        } else if ("building".equals(type)) {
            lwgyBaseBed.setBuildingId(id);
        } else if ("unit".equals(type)) {
            lwgyBaseBed.setUnitId(id);
        } else if ("layer".equals(type)) {
            lwgyBaseBed.setLayerId(id);
        } else if ("room".equals(type)) {
            lwgyBaseBed.setRoomId(id);
        }
        QueryWrapper<LwgyBaseBed> queryWrapper = QueryGenerator.initQueryWrapper(lwgyBaseBed, null);
        /*for (int i = 0; i < list.size(); i++) {
            if("campus".equals(list.get(i).getUniversitySort())){
                if(i >= list.size()-1){
                    queryWrapper.eq("campus_id",list.get(i).getId());
                }else{
                    queryWrapper.eq("campus_id",list.get(i).getId()).or();
                }
            }else if("faculty".equals(list.get(i).getUniversitySort())){
                if (i >= list.size()-1){
                    queryWrapper.eq("faculty_id",list.get(i).getId());
                }else{
                    queryWrapper.eq("faculty_id",list.get(i).getId()).or();
                }
            }else if("major".equals(list.get(i).getUniversitySort())){
                if (i >= list.size()-1){
                    queryWrapper.eq("student_major",list.get(i).getId());
                }else{
                    queryWrapper.eq("student_major",list.get(i).getId()).or();
                }
            }else if("class".equals(list.get(i).getUniversitySort())){
                if(i >= list.size()-1){
                    queryWrapper.eq("student_class",list.get(i).getId());
                }else{
                    queryWrapper.eq("student_class",list.get(i).getId()).or();
                }
            }
        }*/


        queryWrapper.and(
                QueryWrapper ->QueryWrapper.isNull("student_id").
                        or().eq("student_id", "")
        );

        //queryWrapper.isNull("student_id").or().eq("student_id", "");
        queryWrapper.eq("room_sex", roomSex);
        queryWrapper.eq("vb.del_flag", 0);
        queryWrapper.orderByAsc("bed_code");
        IPage<LwgyBaseBed> pageList2 = lwgyBaseBedService.queryPageListCustom(page, queryWrapper);
        try {
            return Result.OK(pageList2);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return Result.OK(null);
        }
    }

    /**
     * 添加
     *
     * @param lwgyBaseBed
     * @return
     */
    @AutoLog(value = "床位信息-添加")
    @ApiOperation(value = "床位信息-添加", notes = "床位信息-添加")
    @PostMapping(value = "/add")
    public Result<?> add(@RequestBody LwgyBaseBed lwgyBaseBed) {
        lwgyBaseBedService.save(lwgyBaseBed);
        return Result.OK("添加成功！");
    }

    /**
     * 编辑
     *
     * @param lwgyBaseBed
     * @return
     */
    @AutoLog(value = "床位信息-编辑")
    @ApiOperation(value = "床位信息-编辑", notes = "床位信息-编辑")
    @PutMapping(value = "/edit")
    public Result<?> edit(@RequestBody LwgyBaseBed lwgyBaseBed) {
		/*LwgyBaseBed updateLwgyBed = new LwgyBaseBed();
		updateLwgyBed.setSchoolId(lwgyBaseBed.getSchoolId());
		updateLwgyBed.setCampusId(lwgyBaseBed.getCampusId());
		updateLwgyBed.setFacultyId(lwgyBaseBed.getFacultyId());
		updateLwgyBed.setBuildingId(lwgyBaseBed.getBuildingId());
		updateLwgyBed.setUnitId(lwgyBaseBed.getUnitId());
		updateLwgyBed.setLayerId(lwgyBaseBed.getLayerId());
		updateLwgyBed.setRoomId(lwgyBaseBed.getRoomId());
		updateLwgyBed.setBedCode(lwgyBaseBed.getName());
		updateLwgyBed.setBedPrice(lwgyBaseBed.getBedPrice());
		updateLwgyBed.setStudentId(lwgyBaseBed.getStudentId());
		updateLwgyBed.setId(lwgyBaseBed.getId());
		updateLwgyBed.setName(lwgyBaseBed.getName());
		System.out.println("updateLwgyBed = " + updateLwgyBed);*/
        lwgyBaseBedService.updateById(lwgyBaseBed);
        return Result.OK("编辑成功!");
    }

    @AutoLog(value = "查询学生年级")
    @ApiOperation(value = "查询学生年级", notes = "查询学生年级")
    @GetMapping(value = "/getYear")
    public Result<?> getYear() {
        List<LwgyBaseSchool> listYear = lwgyBaseBedService.getYear();
        if (listYear.size() == 0) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(listYear);
    }
    /**
     * 修改床位的价格
     *
     * @param bedAndApart
     * @return
     */
    @AutoLog(value = "床位信息-修改")
    @ApiOperation(value = "床位信息-修改", notes = "床位信息-修改")
    @PutMapping(value = "/updatePrice")
    public Result<?> updatePrice(@RequestBody BedAndApart bedAndApart) {
        QueryWrapper<BedAndApart> queryWrapper = new QueryWrapper<>();

        if(oConvertUtils.isNotEmpty(bedAndApart.getCampusId())){
            queryWrapper.eq("t.campus_id",bedAndApart.getCampusId());
        }
        if(oConvertUtils.isNotEmpty(bedAndApart.getBuildingId())){
            queryWrapper.eq("t.building_id",bedAndApart.getBuildingId());
        }
        if(oConvertUtils.isNotEmpty(bedAndApart.getUnitId())){
            queryWrapper.eq("t.unit_id",bedAndApart.getUnitId());
        }
        if(oConvertUtils.isNotEmpty(bedAndApart.getLayerId())){
            queryWrapper.eq("t.layer_id",bedAndApart.getLayerId());
        }
        if(oConvertUtils.isNotEmpty(bedAndApart.getRoomId())){
            queryWrapper.eq("t.room_id",bedAndApart.getRoomId());
        }
        if(oConvertUtils.isNotEmpty(bedAndApart.getStudentYear())){
            queryWrapper.eq("t.student_year",bedAndApart.getStudentYear());
        }
        if(oConvertUtils.isNotEmpty(bedAndApart.getStudentEducation())){
            queryWrapper.eq("t.student_education",bedAndApart.getStudentEducation());
        }
        if(oConvertUtils.isNotEmpty(bedAndApart.getRoomOrientation())){
            queryWrapper.eq("t.room_orientation",bedAndApart.getRoomOrientation());
        }
        List<BedAndApart> bedsList1 = lwgyBaseBedService.getAllBeds(queryWrapper);

        List<LwgyBaseBed> bedsList2 = new ArrayList<>();
        bedsList1.stream().forEach(item -> {
            LwgyBaseBed lwgyBaseBed = new LwgyBaseBed();
            lwgyBaseBed.setId(item.getId());
            lwgyBaseBed.setBedPrice(bedAndApart.getBedPrice());
            bedsList2.add(lwgyBaseBed);
        });
        lwgyBaseBedService.updateBatchById(bedsList2);
        return Result.OK("编辑成功!");
    }

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "床位信息-通过id删除")
    @ApiOperation(value = "床位信息-通过id删除", notes = "床位信息-通过id删除")
    @DeleteMapping(value = "/delete")
    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
        lwgyBaseBedService.removeById(id);
        return Result.OK("删除成功!");
    }

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "床位信息-批量删除")
    @ApiOperation(value = "床位信息-批量删除", notes = "床位信息-批量删除")
    @DeleteMapping(value = "/deleteBatch")
    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
        this.lwgyBaseBedService.removeByIds(Arrays.asList(ids.split(",")));
        System.out.println();
        return Result.OK("批量删除成功!");
    }

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    @AutoLog(value = "床位信息-通过id查询")
    @ApiOperation(value = "床位信息-通过id查询", notes = "床位信息-通过id查询")
    @GetMapping(value = "/queryById")
    public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
        LwgyBaseBed lwgyBaseBed = lwgyBaseBedService.getById(id);
        if (lwgyBaseBed == null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(lwgyBaseBed);
    }


//    /**
//     * 导出excel
//     *
//     * @param request
//     * @param lwgyBaseBed
//     */
//    @RequestMapping(value = "/exportXls")
//    public ModelAndView exportXls(HttpServletRequest request, LwgyBaseBed lwgyBaseBed) {
//        return super.exportXls(request, lwgyBaseBed, LwgyBaseBed.class, "床位信息");
//    }

    /**
     * 导出excel
     *
     * @param request
     * @param
     */
    @RequestMapping(value = "/outXls")
    public ModelAndView outXls(HttpServletRequest request, LwgyBaseBed lwgyBed) {
        List<ImportLwgyBedsA> lwgyBaseBed = lwgyBaseBedService.outBedXls(lwgyBed);
        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
        mv.addObject(NormalExcelConstants.FILE_NAME, "床位信息"); //此处设置的filename无效 ,前端会重更新设置一下
        mv.addObject(NormalExcelConstants.CLASS, ImportLwgyBedsA.class);
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("床位信息", ""));
        mv.addObject(NormalExcelConstants.DATA_LIST, lwgyBaseBed);
        return mv;
    }


    /**
     * 通过excel导入数据
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
        MultipartFile file = fileMap.get("file");
        try {
            ImportParams params = new ImportParams();
            params.setNeedSave(true);
            params.setTitleRows(1);// 设置第一行为标题
            params.setHeadRows(2);// 设置第一行为标题
            List<ImportLwgyBeds> list = ExcelImportUtil.importExcel(file.getInputStream(), ImportLwgyBeds.class, params);
            list.forEach(System.out::println);
            String id;
            Map<String, String> map = new HashMap<>(16);
            Set<LwgyBaseApartment> set = new HashSet<>(500);
            String name;
            bedSet.clear();//用之前先清理
            for (ImportLwgyBeds importLwgyBed : list) {
                id = "0";
                name = importLwgyBed.getCampusName();
                map = lwgyBaseBedService.getApartmentInfo(set, id, name, "campus", map, importLwgyBed);
                name = importLwgyBed.getBuildingName();
                map = lwgyBaseBedService.getApartmentInfo(set, map.get("id"), name, "building", map, importLwgyBed);
                name = importLwgyBed.getUnitName();
                map = lwgyBaseBedService.getApartmentInfo(set, map.get("id"), name, "unit", map, importLwgyBed);
                name = importLwgyBed.getLayerName();
                map = lwgyBaseBedService.getApartmentInfo(set, map.get("id"), name, "layer", map, importLwgyBed);
                name = importLwgyBed.getRoomName();
                map = lwgyBaseBedService.getApartmentInfo(set, map.get("id"), name, "room", map, importLwgyBed);
                name = importLwgyBed.getBedName();
                map = lwgyBaseBedService.getApartmentInfo(set, map.get("id"), name, "bed", map, importLwgyBed);

            }
            List<LwgyBaseApartment> lwgyBaseApartments = set.stream().filter(lwgyBaseSchool -> lwgyBaseSchool.isExistFlag() == false).collect(Collectors.toList());
//            lwgyBaseApartments.forEach(System.out::println);
            lwgyBaseApartmentService.saveBatch(lwgyBaseApartments);
            List<LwgyBaseBed> lwgyBaseBeds = bedSet.stream().filter(bed -> bed.isExistFlag() == false).collect(Collectors.toList());
            System.out.println("-------------------------------");
            lwgyBaseBedService.saveBatch(lwgyBaseBeds);
//            lwgyBaseBeds.forEach(System.out::println);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.OK();

    }


    /**
     * 根据id获取角色
     *
     * @return 返回角色集合
     */
    @AutoLog(value = "根据id获取角色")
    @ApiOperation(value = "根据id获取角色", notes = "根据id获取角色")
    @GetMapping(value = "/getRoleById")
    public Result<?> getRoleById(@RequestParam(name = "id") String id) {
        List<String> roleList = lwgyBaseBedService.getRoleById(id);
        return Result.OK(roleList);
    }

    /**
     * 查询所有学校
     */
    @AutoLog(value = "学校信息-通过pid查询")
    @ApiOperation(value = "学校信息-通过pid查询", notes = "学校信息-通过pid查询")
    @GetMapping(value = "/getSchoolData")
    public Result<?> getSchoolData(HttpServletRequest req, @RequestParam(name = "pid", required = true) String pid) {
        List<Map<String, String>> maps = lwgyBaseBedService.listByPid(pid);
        return Result.OK(maps);
    }

    /**
     * 查询所有学校
     */
/*    @AutoLog(value = "床位信息-通过学校结构查询")
    @ApiOperation(value = "床位信息-通过学校结构查询", notes = "床位信息-通过学校结构查询")
    @GetMapping(value = "/queryPageSchoolBeds")
    public Result<?> queryPageSchoolBeds(HttpServletRequest req,
                                         @RequestParam(name = "id", required = true) String id,
                                         @RequestParam(name = "type", required = false) String type,
                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        System.out.println(id + "= " + type);
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        SysUserCacheInfo cacheUser = commonAPI.getCacheUser(sysUser.getUsername());
        LwgyBaseSchool lwgyBaseSchool = lwgyBaseSchoolService.getById(id);
        String userOrgCode = cacheUser.getSelectedSchools();
        if (oConvertUtils.isNotEmpty(userOrgCode) && !"admin".equals(userOrgCode)) {
            boolean b = permissionTest(userOrgCode, lwgyBaseSchool.getSysOrgCode());
            //包含权限
            if (!b) {
                return Result.OK(new IPage[0]);
            }
        }

        Page<LwgyBaseBed> page = new Page<LwgyBaseBed>(pageNo, pageSize);
        IPage<LwgyBaseBed> ipage = null;
        ipage = lwgyBaseBedService.queryPageFacultyBeds(page, lwgyBaseSchool);
        return Result.OK(ipage);
    }*/


    @PutMapping("/batchUpdateBedsInfo")
    public Result<?> batchUpdateBedsInfo(@RequestBody BatchBedInfo batchBedInfo) {
        String universitySort = lwgyBaseSchoolService.getById(batchBedInfo.getSchoolId()).getUniversitySort();
        String[] apartmentIds = batchBedInfo.getApartmentIds().split(",");
        String apartmentType;
        List<LwgyBaseBed> list = new ArrayList<LwgyBaseBed>(20);
        for (String apartmentId : apartmentIds) {
            if (oConvertUtils.isNotEmpty(apartmentId)) {
                apartmentType = lwgyBaseApartmentService.getById(apartmentId).getType();
                List<LwgyBaseBed> bedIdList = lwgyBaseBedService.getBedIdList(apartmentId, apartmentType);
                list.addAll(bedIdList);
            }
        }
        String[] bedIds = batchBedInfo.getBedIds().split(",");
        LwgyBaseBed lwgyBaseBed;
        for (String bedId : bedIds) {
            if (oConvertUtils.isNotEmpty(bedId)) {
                lwgyBaseBed = new LwgyBaseBed();
                lwgyBaseBed.setId(bedId);
                list.add(lwgyBaseBed);
            }
        }
        if ("campus".equals(universitySort)) {
            list.forEach(lwgybed -> lwgybed.setCampusId(batchBedInfo.getSchoolId()));
        } else if ("faculty".equals(universitySort)) {
            list.forEach(lwgybed -> lwgybed.setFacultyId(batchBedInfo.getSchoolId()));
        } else if ("major".equals(universitySort)) {
            list.forEach(lwgybed -> lwgybed.setStudentMajor(batchBedInfo.getSchoolId()));
        } else if ("class".equals(universitySort)) {
            list.forEach(lwgybed -> lwgybed.setStudentClass(batchBedInfo.getSchoolId()));
        }

        boolean b = lwgyBaseBedService.updateBatchById(list);
        if (b) {
            return Result.OK();
        }
        return Result.error("更新失败");
    }


    /***
     * 用户权限校验
     * @param userCode
     * @param schoolCode
     * @return
     */
    public boolean permissionTest(String userCode, String schoolCode) {
        String[] fields = userCode.split(",");
        String result = "";
        boolean b;
        for (String field : fields) {
            b = schoolCode.startsWith(field);
            result += b;
        }
        boolean aTrue = result.contains("true");
        return aTrue;
    }

    /**
     * 根据床位信息获取学生信息
     */
    @ApiOperation(value = "根据床位查询学生信息")
    @GetMapping("/getStuInfoByBedId")
    public Result<?> getStuInfoByBedId(String bedId) {
        LwgyBaseStudent lwgyBaseStudent = lwgyBaseBedService.getStuInfoByBedId(bedId);
        return Result.OK(lwgyBaseStudent);
    }

    /**
     * 根据床位信息获取学生信息
     */
    @ApiOperation(value = "根据房间查询学生信息")
    @GetMapping("/getStuInfoByRoomId")
    public Result<?> getStuInfoByRoomId(String RoomId) {
        Page<LwgyBaseStudent> page = new Page<>();
        IPage<LwgyBaseStudent> stuInfoList = lwgyBaseBedService.getStuInfoByRoomId(page, RoomId);
        return Result.OK(stuInfoList);
    }

    public LoginUser getSysUser() {
        return (LoginUser) SecurityUtils.getSubject().getPrincipal();
    }



//------------------假期----start
    /**
     * 根据部门id查询用户信息
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/queryHolidayBedByScInfoId", method = RequestMethod.GET)
    public Result<?> queryHolidayBedByScInfoId(@RequestParam(name = "id", required = false) String id,/*@RequestBody LwgyBaseApartment lwgyBaseApartment0,*/
                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                        @RequestParam(name = "roomSex", required = false) String roomSex) {
        if (id == null) {
            return Result.OK(null);
        }
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String selectedSchools = sysUser.getSelectedSchools();
        String[] fields = selectedSchools.split(",");
        List<String> fieldList = Arrays.asList(fields);

        QueryWrapper<LwgyBaseSchool> wrapper = new QueryWrapper();
        wrapper.in("sys_org_code", fieldList);
        List<LwgyBaseSchool> list = lwgyBaseSchoolService.getBaseMapper().selectList(wrapper);
        Map<String, String> map = new HashMap<>(3);


        LwgyBaseApartment lwgyBaseApartment = lwgyBaseApartmentService.getById(id);
        Page<LwgyBaseBed> page = new Page<>(pageNo, pageSize);
        LwgyBaseBed lwgyBaseBed = new LwgyBaseBed();
        String type = lwgyBaseApartment.getType();
        if ("campus".equals(type)) {
            lwgyBaseBed.setCampusId(id);
        } else if ("building".equals(type)) {
            lwgyBaseBed.setBuildingId(id);
        } else if ("unit".equals(type)) {
            lwgyBaseBed.setUnitId(id);
        } else if ("layer".equals(type)) {
            lwgyBaseBed.setLayerId(id);
        } else if ("room".equals(type)) {
            lwgyBaseBed.setRoomId(id);
        }
        QueryWrapper<LwgyBaseBed> queryWrapper = QueryGenerator.initQueryWrapper(lwgyBaseBed, null);


        queryWrapper.and(
                    QueryWrapper ->QueryWrapper.isNull("holiday_student_id").
                            or().eq("holiday_student_id", "")
            );

        queryWrapper.eq("room_sex", roomSex);
        queryWrapper.orderByAsc("bed_code");
        IPage<LwgyBaseBed> pageList2 = lwgyBaseBedService.queryPageListCustom(page, queryWrapper);
        try {
            return Result.OK(pageList2);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return Result.OK(null);
        }
    }

    /**
     * 自定义分页列表查询
     *
     * @param lwgyBaseBed
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "床位信息-分页列表查询")
    @ApiOperation(value = "床位信息-分页列表查询", notes = "床位信息-分页列表查询")
    @GetMapping(value = "/listCustomHoliday")
    public Result<?> queryPageListCustomHoliday(LwgyBaseBed lwgyBaseBed,
                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                         @RequestParam(name = "studentName",required = false) String studentName,
                                         @RequestParam(name = "studentNumber",required = false) String studentNumber,
                                         @RequestParam(name = "roomSex",required = false) String roomSex,
                                         HttpServletRequest req) {
        String type = lwgyBaseBed.getType();
        String id = lwgyBaseBed.getId();
        if(oConvertUtils.isEmpty(type)){
            LwgyBaseApartment lwgyBaseApartment = lwgyBaseApartmentService.getById(id);
            type = lwgyBaseApartment.getType();
        }

        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<String> role = lwgyBaseBedService.getRoleById(sysUser.getId());
        if (role.contains("fdy")) {//不是管理员，显示管理员分配的的床位
            String workNo = sysUser.getWorkNo();
            lwgyBaseBed.setAdminId(workNo);
        }
        if (type != null) {
            if ("school".equals(type)) {
                lwgyBaseBed.setSchoolId(id);
            } else if ("campus".equals(type)) {
                lwgyBaseBed.setCampusId(id);
            } else if ("faculty".equals(type)) {
                lwgyBaseBed.setFacultyId(id);
            } else if ("building".equals(type)) {
                lwgyBaseBed.setBuildingId(id);
            } else if ("unit".equals(type)) {
                lwgyBaseBed.setUnitId(id);
            } else if ("layer".equals(type)) {
                lwgyBaseBed.setLayerId(id);
            } else if ("room".equals(type)) {
                lwgyBaseBed.setRoomId(id);
            }
        }
//		lwgyBaseBed.setType(null);
        lwgyBaseBed.setId(null);
        QueryWrapper<LwgyBaseBed> queryWrapper = QueryGenerator.initQueryWrapper(lwgyBaseBed, req.getParameterMap());
        Page<LwgyBaseBed> page = new Page<>(pageNo, pageSize);
        if (StringUtils.isNotBlank(roomSex)) {
            queryWrapper.eq("room_sex", roomSex);
        }
        if (StringUtils.isNotBlank(studentName)){
            queryWrapper.eq("student_name",studentName);
        }
        if (StringUtils.isNotBlank(studentNumber)){
            queryWrapper.eq("student_number",studentNumber);
        }

        queryWrapper.eq("del_flag",0);
        queryWrapper.orderByAsc("room_id");

        IPage<LwgyBaseBed> pageList2 = lwgyBaseBedService.queryHolidayPageListCustom(page, queryWrapper);
        return Result.OK(pageList2);
    }

    //---------------假期相關end----


    /**---------------住宿分配 - Start---------------*/

    @AutoLog(value = "lwgy_base_bed-分页列表查询")
    @ApiOperation(value = "lwgy_base_bed-分页列表查询", notes = "lwgy_base_bed-分页列表查询")
    @GetMapping(value = "/listBed")
    public Result<?> queryPageNullBed(LwgyBedAssignment lwgyBedAssignment,
                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                      @RequestParam(name = "isAdminId", required = false) String isAdminId,
                                      @RequestParam(name = "isBed", required = false) String isBed,
                                      HttpServletRequest req) {
        String type = lwgyBedAssignment.getType();
        String id = lwgyBedAssignment.getId();
        if(oConvertUtils.isEmpty(type)){
            LwgyBaseApartment lwgyBaseApartment = lwgyBaseApartmentService.getById(id);
            type = lwgyBaseApartment.getType();
        }
        Page<LwgyBedAssignment> page = new Page<>(pageNo, pageSize);
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<String> roles = sysBaseAPI.getRolesByUsername(sysUser.getUsername());
        if (roles.contains("fdy")) {//不是管理员，显示管理员分配的的床位
            String workNo = sysUser.getWorkNo();
            lwgyBedAssignment.setAdminId(workNo);

        }
        if (type != null) {
            if ("campus".equals(type)) {
                lwgyBedAssignment.setCampusId(id);
            }  else if ("building".equals(type)) {
                lwgyBedAssignment.setBuildingId(id);
            } else if ("unit".equals(type)) {
                lwgyBedAssignment.setUnitId(id);
            } else if ("layer".equals(type)) {
                lwgyBedAssignment.setLayerId(id);
            } else if ("room".equals(type)) {
                lwgyBedAssignment.setRoomId(id);
            }
        }
        lwgyBedAssignment.setId(null);
        QueryWrapper<LwgyBedAssignment> queryWrapper = QueryGenerator.initQueryWrapper(lwgyBedAssignment, req.getParameterMap());

        if (isAdminId != null) {
            if ("0".equals(isAdminId)) {
                queryWrapper.eq("t1.is_admin_id",0);
            } else if ("1".equals(isAdminId)) {
                queryWrapper.eq("t1.is_admin_id",1);
            }
        }
        if (isBed != null) {
            if ("0".equals(isBed)) {
                queryWrapper.eq("t1.is_bed",0);
            } else if ("1".equals(isBed)) {
                queryWrapper.eq("t1.is_bed",1);
            }
        }
        IPage<LwgyBedAssignment> pageList = lwgyBaseBedService.queryPageNullBed(page, queryWrapper);
        return Result.OK(pageList);
    }

    /**---------------住宿分配 - End---------------*/


    /**---------------禁用激活床位 - Start---------------*/
    /**
     * 批量禁用
     *
     */
    @AutoLog(value = "批量禁用")
    @ApiOperation(value = "批量禁用", notes = "批量禁用")
    @PostMapping(value = "/disableBed")
    public Result<?> disableBed(@RequestBody List<Map<String, String>> roomList) {
        String ids = "";
        for (Map<String, String> map : roomList) {
            ids += map.get("ids") + ",";
        }
        // 批量禁用
        lwgyBaseBedService.disableBed(ids);
        return Result.OK("编辑成功!");
    }
    /**
     * 批量激活
     *
     */
    @AutoLog(value = "批量激活")
    @ApiOperation(value = "批量激活", notes = "批量激活")
    @PostMapping(value = "/activateBed")
    public Result<?> activateBed(@RequestBody List<Map<String, String>> roomList) {
        String ids = "";
        for (Map<String, String> map : roomList) {
            ids += map.get("ids") + ",";
        }
        // 批量禁用
        lwgyBaseBedService.activateBed(ids);
        return Result.OK("编辑成功!");
    }
    /**---------------禁用激活床位 - End---------------*/
}
